#!/bin/bash

echo "🧪 测试 DCarPai UBBC 系统..."
echo "=============================="

# 检查文件是否存在
echo "📁 检查项目文件..."
files=("package.json" "src/App.tsx" "src/main.tsx" "server/server.js" "data/ubbc-rules.json")

for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        echo "✅ $file"
    else
        echo "❌ $file 不存在"
    fi
done

# 检查Node.js和npm
echo ""
echo "🔧 检查环境..."
if command -v node &> /dev/null; then
    echo "✅ Node.js: $(node --version)"
else
    echo "❌ Node.js 未安装"
fi

if command -v npm &> /dev/null; then
    echo "✅ npm: $(npm --version)"
else
    echo "❌ npm 未安装"
fi

# 检查依赖
echo ""
echo "📦 检查依赖..."
if [ -d "node_modules" ]; then
    echo "✅ 依赖已安装"
    
    # 检查关键依赖
    key_deps=("react" "antd" "express" "typescript" "vite")
    for dep in "${key_deps[@]}"; do
        if [ -d "node_modules/$dep" ]; then
            echo "  ✅ $dep"
        else
            echo "  ❌ $dep 未安装"
        fi
    done
else
    echo "❌ 依赖未安装，请运行 ./install.sh"
fi

echo ""
echo "🎯 测试完成！"
